  {  Petrova Tatjana
     2012/10/21
     This program writes pi.}

program Number;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  N1,N2: integer;
  x,y:double;
  d,b:real;
  fin :Textfile ;
begin
  assignFile(fin, 'Table.txt');
  rewrite(fin);
  while (1=1) do
  begin
    y:=2*random;
    x:=2*random;
    if ((x-1)*(x-1)+(y-1)*(y-1)=1) or  ((x-1)*(x-1)+(y-1)*(y-1)<1)then
    begin
      N1:=N1+1;
      N2:=N2+1
    end else
      N1:=N1+1;
    if ((N1 mod 1000)=0) then
    begin
      d:=4*((N2 div N1) + (N2 mod N1));
      b:=abs(pi-d);
      writeln(fin,b,' ',N1);
    end;
  end;


end.
